var app = getApp();
Page( Object.assign({},{
    data:{
        page : {
            isend : false,
            doing : false,
            doo : 'comm',
            pdata : {
                op : 'list',
                page : 1,
                gid : 0,
            },
            waitf : 0,
            nodataf : 0,
        },
        datalist : [],
        ising : false,
		siteroot : app.siteInfo.siteroot.replace('app/index.php', ''),uniacid: app.siteInfo.uniacid,
    },
    onLoad:function(options){
        var self = this;

        var id = options.id ? options.id : ( options.scene ? options.scene : 0 );
        var zfid = options.zfid ? options.zfid : '';
        
        app.com.auth(function(){
            app.com.http('comm','POST',{op:'info',id:id,zfid:zfid},10,false,'','',function(res){
                if (!res.data.errno) {
                    self.setData({
                    	Pagetheme : res.data.data.params.style,
                        info : res.data.data.info,
                        good : res.data.data.good,
                        sharedata : res.data.data.sharedata,
                        params : res.data.data.params,
                        user : res.data.data.user,
                    },function(){
                        self.setData({
                            inited : true,
                            'page.pdata.gid': res.data.data.good.id,
                            'page.pdata.showid' : res.data.data.info.id,
                        });

                        app.com.getPage(self,self.data.page,20,function(res){
                            self.setData({
                                datalist : res.data.data.list
                            });
                        });

                    });
                    wx.setNavigationBarTitle({
                        title: res.data.data.params.title ? res.data.data.params.title : '评价'
                    });
                    // 关闭下拉刷新
                    wx.stopPullDownRefresh();

                }else{
                    app.com.alert(res.data.message);
                }
            });
        });

    },
    onPullDownRefresh: function () {
        wx.stopPullDownRefresh();
    },
    onShareAppMessage : function(){
        var self = this;
        return {
            title: self.data.sharedata.title,
            path: self.data.sharedata.path,
            imageUrl : self.data.sharedata.img,
        }
    },
    onReachBottom : function(){
        var self = this;

        app.com.getPage(self,self.data.page,20,function(res){
            self.setData({
                datalist : self.data.datalist.concat(res.data.data.list)
            });
        });
    },
    favorclick(e){
        var self = this;
        var postdata = {
            op : 'favorclick',
            cid : e.currentTarget.dataset.cid,
        };
        app.com.http('comm','POST',postdata,0,true,'','',function(res){
            if (!res.data.errno && res.data) {
                var now = self.data.info.zan*1 + 1;
                self.setData({
                   'info.zan' : now,
                   'info.zaned' : 1,
                });
            }else{
                app.com.toast( res.data.message );
            }
        });
    },
    location : function( e ){
        app.com.location( e );
    },
    otherapp : function( e ){
        app.com.otherapp( e );
    },
    navigateto : function( e ){
        app.com.navigateto( e,this.data.tid );
    },
    redirectto : function( e ){
        app.com.redirectto( e,this.data.tid );
    },    
    callphone : function(e){
        app.com.callphone( e );
    },
    showimages : function( e ){
        app.com.showimages( e );
    },
    FormIdsubmit : function(e){

    },
    footNavigate(e){
        var url = e.currentTarget.dataset.url;
        wx.switchTab({
          url: url
        })
    },
    showJoin(e){
        var self = this;
        self.setData({
            Joinanimation : !self.data.Joinanimation,
        })
    },
    FormIdsubmit : function(e){
        if( app.globalData.formarr.length <= 20 ) app.globalData.formarr.push(e.detail.formId);
    },
    
}))